#include "about.h"
#include "ui_about.h"

about::about(Gobang_Network *gn, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::about)
{
    this->gn = gn;
    ui->setupUi(this);

    connect(gn->t, SIGNAL(rx_version(uint8_t)),
                this, SLOT(rx_version(uint8_t)));
}

about::~about()
{
    delete ui;
}

void about::setSize(int x, int y, int w, int h)
{
    this->ui->verticalLayoutWidget->setGeometry(x,y,w,h);
}

void about::rx_version(uint8_t ver)
{
    if (ver > GAME_VERSION) {
        //提问对话框
        // 参数 父亲，标题，提示内容，关联案件类型,默认关联回车按键类型，
        if(QMessageBox::Yes == QMessageBox::question(this,"提示","拥有最新版本，是否更新?", QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes))
        {
            QDesktopServices::openUrl(QUrl(QString("http://dbcx.asia/src/exe/gobang.exe")));
        }

    } else {
        QMessageBox::question(this,
               tr("提示:"),
               tr("你现在是最新版本"),
               QMessageBox::Ok,
               QMessageBox::Ok);
    }

    qDebug()<<ver<<"   "<<GAME_VERSION;
}

void about::on_pushButton_clicked()
{
    this->gn->t->tx_uint8(A_GET_VERSION, 0);
}
